﻿using UnityEngine;
using UnityEngine.UI;

namespace Model
{
  public class UIItem : MonoBehaviour
  {
    /// <summary>
    /// 显示数量
    /// </summary>
    public Text text;
    /// <summary>
    /// 显示图片
    /// </summary>
    public Image image;

    public void Show(ItemViewModel vm)
    {
      if (vm.Count > 1)
        text.text = vm.Count.ToString();
      else
        text.text = "";

      Sprite sprite = Resources.Load<Sprite>(vm.Item.Image);
      image.sprite = sprite;
    }
  }
}